# import os
# import subprocess
# import sys
#
# print(f"当前的工作目录：{os.getcwd()}")
#
# python_path = sys.executable  # 可执行的python
# run_path = r"D:\study\w_code\Tesla\api_frame\run.py"
#
# path_list = [
#     r"D:\study\w_code\Tesla\api_frame\tests\yaml_case\bbs",
#     r"D:\study\w_code\Tesla\api_frame\tests\yaml_case\ddt",
#     r"D:\study\w_code\Tesla\api_frame\tests\yaml_case\weixin",
#     r"D:\study\w_code\Tesla\api_frame\tests\yaml_case\加密用例",
#     r"D:\study\w_code\Tesla\api_frame\tests\yaml_case\商城用例",
#     r"D:\study\w_code\Tesla\api_frame\tests\yaml_case\流程用例",
# ]
# test_yam_case = r"D:\\study\\w_code\\Tesla\\api_frame\\tests\\test_yaml_case.py"
#
# for path in path_list:
#     # 在子进程中设置 cwd   子进程执行cmd /c dir时,他的cwd时我们自己指定的！！！
#     proc = subprocess.run(f"{python_path} {run_path}",
#                           # 子进程执行的结果和我们自己进入到这个目录下执行dir的结果是一样的
#                           cwd=path,
#                           stdout=subprocess.PIPE,
#                           stderr=subprocess.PIPE
#                           )
#
#     try:
#         print(proc.stdout.decode("utf-8"))
#         print(proc.stderr.decode("utf-8"))
#     except UnicodeDecodeError:
#         print(proc.stdout.decode("gbk"))
#         print(proc.stderr.decode("gbk"))

# 并发执行demo
import time
from concurrent.futures.thread import ThreadPoolExecutor

test_path = [1, 2, 3, 4, 5]


def echo(path):
    print("开始时间：", time.time())
    time.sleep(2)
    print(path)


pool = ThreadPoolExecutor(max_workers=6)

pool.map(echo, test_path)
